package com.degisn.normal;

import com.degisn.Matter;
import com.degisn.ceiling.LevelOneCeiling;
import com.degisn.ceiling.LevelTwoCeiling;
import com.degisn.coat.DuluxCoat;
import com.degisn.coat.LiBangCoat;
import com.degisn.floor.ShengXiangFloor;
import com.degisn.tile.DongPengTile;
import com.degisn.tile.MarcoPoloTile;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;

/**
 * 正常情况下编写方式
 * @author ytj
 * @date 2021/12/24
 */
public class DecorationPackageController {

    /**
     * @param area 装修面积
     * @param level 等级
     * */
    public String getMatterList(BigDecimal area,Integer level){
        List<Matter> list=new ArrayList<>();//装修清单
        BigDecimal price=BigDecimal.ZERO;//装修价格

        //豪华欧式
        if(level==1){
            LevelTwoCeiling levelTwoCeiling=new LevelTwoCeiling();//吊顶:二级
            DuluxCoat duluxCoat=new DuluxCoat();  //涂料:多乐士
            ShengXiangFloor shengXiangFloor=new ShengXiangFloor(); //地板:圣像

            list.add(levelTwoCeiling);
            list.add(duluxCoat);
            list.add(shengXiangFloor);

            price=price.add(area.multiply(new BigDecimal("0.2").multiply(levelTwoCeiling.price())));
            price=price.add(area.multiply(new BigDecimal("1.4")).multiply(duluxCoat.price()));
            price=price.add(area.multiply(shengXiangFloor.price()));
        }

        //轻奢田园
        if(level==2){
            LevelTwoCeiling levelTwoCeiling=new LevelTwoCeiling();//吊顶二级
            LiBangCoat liBangCoat=new LiBangCoat(); //涂料立邦
            MarcoPoloTile marcoPoloTile=new MarcoPoloTile(); //地砖马可波罗

            list.add(levelTwoCeiling);
            list.add(liBangCoat);
            list.add(marcoPoloTile);

            price=price.add(area.multiply(new BigDecimal("0.2")).multiply(levelTwoCeiling.price()));
            price=price.add(area.multiply(new BigDecimal("1.4")).multiply(liBangCoat.price()));
            price=price.add(area.multiply(marcoPoloTile.price()));
        }

        //现代简约
        if(level==3){
            LevelOneCeiling levelOneCeiling=new LevelOneCeiling();
            LiBangCoat liBangCoat=new LiBangCoat();
            DongPengTile dongPengTile=new DongPengTile();

            list.add(levelOneCeiling);
            list.add(liBangCoat);
            list.add(dongPengTile);

            price=price.add(area.multiply(new BigDecimal("0.2").multiply(levelOneCeiling.price())));
            price=price.add(area.multiply(new BigDecimal("1.4")).multiply(liBangCoat.price()));
            price=price.add(area.multiply(dongPengTile.price()));
        }
        StringBuilder detail = new StringBuilder("\r\n-------------------------------------------------------\r\n" +
                "装修清单" + "\r\n" +
                "套餐等级：" + level + "\r\n" +
                "套餐价格：" + price.setScale(2, BigDecimal.ROUND_HALF_UP) + " 元\r\n" +
                "房屋面积：" + area.doubleValue() + " 平米\r\n" +
                "材料清单：\r\n");
        for (Matter matter : list) {
            detail.append(matter.scene()).append("：").append(matter.brand()).append("、").append(matter.model()).append("、平米价格：").append(matter.price()).append(" 元。\n");
        }

        return detail.toString();
    }
}
